/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Dsrv6.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "insurance_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "InsuranceType.findAll", query = "SELECT i FROM InsuranceType i"),
    @NamedQuery(name = "InsuranceType.findByInstId", query = "SELECT i FROM InsuranceType i WHERE i.instId = :instId"),
    @NamedQuery(name = "InsuranceType.findByCode", query = "SELECT i FROM InsuranceType i WHERE i.code = :code"),
    @NamedQuery(name = "InsuranceType.findByDescr", query = "SELECT i FROM InsuranceType i WHERE i.descr = :descr")})
public class InsuranceType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "INST_ID")
    private Long instId;
    @Basic(optional = false)
    @Column(name = "CODE")
    private String code;
    @Basic(optional = false)
    @Column(name = "DESCR")
    private String descr;
    @OneToMany(mappedBy = "instInstId")
    private List<Register> registerList;

    public InsuranceType() {
    }

    public InsuranceType(Long instId) {
        this.instId = instId;
    }

    public InsuranceType(Long instId, String code, String descr) {
        this.instId = instId;
        this.code = code;
        this.descr = descr;
    }

    public Long getInstId() {
        return instId;
    }

    public void setInstId(Long instId) {
        this.instId = instId;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescr() {
        return descr;
    }

    public void setDescr(String descr) {
        this.descr = descr;
    }

    @XmlTransient
    public List<Register> getRegisterList() {
        return registerList;
    }

    public void setRegisterList(List<Register> registerList) {
        this.registerList = registerList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (instId != null ? instId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof InsuranceType)) {
            return false;
        }
        InsuranceType other = (InsuranceType) object;
        if ((this.instId == null && other.instId != null) || (this.instId != null && !this.instId.equals(other.instId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "maae.persistence.entities.InsuranceType[ instId=" + instId + " ]";
    }
    
}
